import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import mplfinance as mpf
import matplotlib.dates as mdates
import datetime as dt
import plotly.graph_objects as go
import plotly.express as px
import plotly.io as pio
from plotly.subplots import make_subplots
pio.renderers.default = "notebook"
pio.templates.default = "plotly_dark"
import gc
np.random.seed(42)
import warnings
warnings.filterwarnings("ignore")
plt.rcParams["figure.figsize"] = [12, 8]
An inverted yield curve is a situation in which short term interest rates, like overnight rates or three month rates, are above long term interest rates. Inverted yield curves have often heralded a recession.
three_m = pd.read_csv("Data/3M.csv", index_col="Date", parse_dates=True)
six_m = pd.read_csv("Data/6M.csv", index_col="Date", parse_dates=True)
ten_y = pd.read_csv("Data/10Y.csv", index_col="Date", parse_dates=True)
thirty_y = pd.read_csv("Data/30Y.csv", index_col="Date", parse_dates=True)
us_13_w = pd.read_csv("Data/US13W.csv", index_col="Date", parse_dates=True)
us_10_y = pd.read_csv("Data/US10Y.csv", index_col="Date", parse_dates=True)
us_5_y = pd.read_csv("Data/US5Y.csv", index_col="Date", parse_dates=True)
us_30_y = pd.read_csv("Data/US30Y.csv", index_col="Date", parse_dates=True)
fig = go.Figure()
fig.add_scatter(
x=us_30_y.index,
y=us_30_y["Close"],
name="US 30 Year Treasury Yield",
line=dict(color="red", width=1),
)
fig.add_scatter(
x=us_10_y.index,
y=us_10_y["Close"],
name="US 10 Year Treasury Yield",
line=dict(color="blue", width=1),
)
fig.add_scatter(
x=us_5_y.index,
y=us_5_y["Close"],
name="US 5 Year Treasury Yield",
line=dict(color="green", width=1),
)
# fig.add_scatter(
# x=us_13_w.index,
# y=us_13_w["Close"],
# name="US 13 Week Treasury Yield",
# line=dict(color="yellow", width=1),
# )
fig.update_layout(
title="US Treasury Yield Curve",
xaxis_title="Date",
yaxis_title="Yield",
font=dict(family="Courier New, monospace", size=18, color="#7f7f7f"),
)
fig.show()
thirty_y.sort_index(inplace=True, ascending=True)
thirty_y = thirty_y.drop_duplicates()
fig = go.Figure()
fig.add_scatter(
x=six_m.index,
y=six_m["Close"],
name="6M",
line=dict(color="green", width=1),
)
fig.add_scatter(
x=ten_y.index,
y=ten_y["Close"],
name="10Y",
line=dict(color="blue", width=1),
)
fig.add_scatter(
x=thirty_y.index,
y=thirty_y["Close"],
name="30Y",
line=dict(color="white", width=1),
)
fig.update_layout(
title="Indian Treasury Yield Curve",
xaxis_title="Date",
yaxis_title="Yield",
font=dict(family="Courier New, monospace", size=18, color="#7f7f7f"),
)
fig.show()
data = [us_5_y["Close"][4910], us_10_y["Close"][4910], us_30_y["Close"][4910]]
labels = ["US 5Y", "US 10Y", "US 30Y"]
fig = go.Figure()
fig.add_trace(
go.Scatter(
x=labels,
y=data,
marker_color=["blue", "green", "red"],
name="US Treasury Yield",
)
)
fig.update_layout(
title=f"US Treasury Yield Curve on {us_5_y.iloc[4910].name.strftime('%Y-%m-%d')}",
xaxis_title="Date",
yaxis_title="Yield",
font=dict(family="Courier New, monospace", size=18, color="#7f7f7f"),
)
data = [three_m["Close"][-1], six_m["Close"][-1], ten_y["Close"][-1], thirty_y["Close"][-1] ]
labels = ["3M", "6M", "10Y", "30Y"]
fig = go.Figure()
fig.add_trace(
go.Scatter(
x=labels,
y=data,
marker_color=["blue", "green", "red", "yellow"],
name="Indian Treasury Yield",
)
)
fig.update_layout(
title="Indian Treasury Yield Curve",
xaxis_title="Time",
yaxis_title="Yield",
font=dict(family="Courier New, monospace", size=18, color="#7f7f7f"),
)
fig.show()
The LIBOR-OIS spread represents the difference between an interest rate with some credit risk built-in and one that is virtually free of such hazards. Therefore, when the gap widens, it’s a good sign that the financial sector is on edge.
We have it as a verb. To mortgage something, to mortgage your house means to offer it as collateral for a loan. So when you get a mortgage on your house, typically it is to buy the house, the bank lends you the money to buy the house, but if you stop paying on the mortgage, they can reclaim the house.
Underwater: The term underwater is used to describe a situation in which the value of a home is less than the amount of money owed on the mortgage. If you are underwater, you are in a negative equity situation.
Not everyone can invest in real state. You must be "wealthy enough" to do so. The reason is that real estate is a very illiquid asset. It is very hard to sell at a price that you want. So, if you are a wealthy person, you can afford to buy a house and hold it for a long time. If you are not wealthy, you cannot afford to buy a house and hold it for a long time. You need to be able to sell it quickly if you need to.
m_15_us = pd.read_csv("Data/MORTGAGE15US.csv", index_col="DATE", parse_dates=True)
m_30_us = pd.read_csv("Data/MORTGAGE30US.csv", index_col="DATE", parse_dates=True)
fig = go.Figure()
fig.add_scatter(
x=m_15_us.index,
y=m_15_us["MORTGAGE15US"],
name="15 Year Mortgage Rate",
line=dict(color="red", width=1),
)
fig.add_scatter(
x=m_30_us.index,
y=m_30_us["MORTGAGE30US"],
name="30 Year Mortgage Rate",
line=dict(color="blue", width=1),
)
fig.update_layout(
title="US Mortgage Rate",
xaxis_title="Date",
yaxis_title="Rate",
font=dict(family="Courier New, monospace", size=18, color="#7f7f7f"),
)
fig.show()
Amortization means, paying off the principal. Your payment comes in two parts. One of them is interest. One of them is amortization.
Here are some of the most common types of mortgages:
PMI is a type of insurance you might be required to pay for if you have a conventional loan and make a down payment that is less than 20 percent of the home’s purchase price. PMI protects the lender on a conventional mortgage in the event that the borrower defaults and the lender is forced to foreclose.
Reserve requirements that banks have to keep a certain amount of cash on reserve to meet any sudden increase in demand from their depositors.
Excess reserves are the reserves that banks hold beyond what they're required to hold by regulation.

Usually, homeowners are better citizens and hence tax policy encourages home ownership.
The word tunneling is often used to describe tricks that people in companies use to steal money from the company.
This can be achieved by:
They are private institutes which are mainly for wealthy investors. All the investors should be "accredited investors" (In US this means that they must have income of at least $200,000 or investable assets of $2,500,000). This form the "3c1" kind of gendge fund where maximum number of investors is 99.
The "3c7"s are the hedge funds which can have at most 500 "qualified purchasers" (individuals with net worth greater than $5 Million or institutions with net worth greater than $25 Million).
This was defined in 2006.
Usually, a company starts as private and then becomes public through an IPO. The company must be approved by the SEC to go public. The reverse of this is also possible.
Insiders are people with special knowledge because of connections about a company. Inside information represents wealth. If you know something that the general investing public doesn't know, that's an opportunity for you to trade on that information.
Front running is a form of market manipulation in which a broker, investment advisor, or trader executes orders ahead of the client's order, based on the client's order. This is illegal.
GAAP is a set of accounting standards that companies must follow when they report their financial statements to the public. The SEC requires that companies follow GAAP when they report their financial statements to the public.